﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System;
using System.Threading;
using System.ComponentModel;
using BrainTechLLC.ThreadSafeObjects;
using System.Runtime.Serialization;

namespace BrainTechLLC
{
    [DataContract]
    public class NotificationMessageText : ICanCustomSerialize, IRegisterAsSerializable
    {
        [DataMember]
        public string Text { get; set; }

        public int SerializeOut(BinaryWriter b)
        {
            b.Write(Text);
            return Text.Length;
        }

        public int SerializeIn(object o, BinaryReader b)
        {
            NotificationMessageText msg = o as NotificationMessageText;
            msg.Text = b.ReadString();
            return msg.Text.Length;
        }

        public int TransmissionType { get { return (int)TransmissionEnum.NotificationMessageText; } }

        public static void Register()
        {
            ((int)TransmissionEnum.NotificationMessageText).RegisterType(typeof(NotificationMessageText));
        }
    }

    [DataContract]
    public class NotificationMessageTextWithSource : ICanCustomSerialize, IRegisterAsSerializable
    {
        [DataMember]
        public string Text { get; set; }

        [DataMember]
        public string Source { get; set; }

        public int SerializeOut(BinaryWriter b)
        {
            b.Write(Text);
            b.Write(Source);
            return Text.Length;
        }

        public int SerializeIn(object o, BinaryReader b)
        {
            NotificationMessageTextWithSource msg = o as NotificationMessageTextWithSource;
            msg.Text = b.ReadString();
            msg.Source = b.ReadString();
            return msg.Text.Length;
        }

        public int TransmissionType { get { return (int)TransmissionEnum.NotificationMessageTextWithSource; } }

        public static void Register()
        {
            ((int)TransmissionEnum.NotificationMessageTextWithSource).RegisterType(typeof(NotificationMessageTextWithSource));
        }
    }

}
